The MYSQL Cast function is a very important MYSQL function. The following describes the syntax and usage of the MYSQL Cast function in detail, hoping that you can have a better understanding of the MYSQL Cast function.
BINARYThe BINARY operator
In mysql, if I use common data sorting methods, we may not get the expected results, but mysql provides us with the CAST CONVERT function, which can CONVERT numbers accordingly, I used this function to sort Chinese characters in the past.
Let's
SQL case-sensitive-reprint
①
You do not have to install it to differentiateCase sensitivity, Directly convert the value to be comparedBinaryAffect performance. ② add rules, not supported by sql7Compare the following two items:Print cast
Simple to say about MySQL's varchar sorting problem, a cautionary tale.
Sample Table structure:
Let's take a look at my table structure
code is as follows
copy code
Show create table Cardserver G **************
SQL Server defaults to case-insensitive queries, but sometimes some query statements require a case-sensitive query, which requires some special handling. There are two main ways of distinguishing between case and case.Turn binary judgmentSELECT *
Table
Alter table name
Alter column name nvarchar (100) (type) Collate chinese_prc_ci_as
-- Case insensitive
ALTER TABLE TBAlter column colname nvarchar (100) Collate chinese_prc_cs_as-- Case sensitive
Modify to fieldAlso, in the design
Town Field Poem:The Pure Heart sentiment wisdom language, does not have the world name and the benefit. Learn water under the hundred rivers, give up arrogant slow meaning.Learn to have a small return to feed root, willing to cast a conscience blog.
Search for a lot of related information on the Internet and summarize the reasons for this situation mainly because of sorting rules:If no sorting rule is specifiedWhether the temporary table is case sensitive depends on the order of the tempdb
By default, SQLServer is case insensitive. For example, userNamejesse and userNameJESSE have the same results. When the password is verified, it may be case sensitive to the string and some processing is required. Two methods are introduced: method
Case
in SQL2000 and 7.0 query statements, distinguish uppercase query methods
--sql2000, use the following method.
--that is, add collate chinese_prc_cs_as_ws after the field name
--a method for distinguishing case and full half-width
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.